package array.easy;

/**
 * 1827. 最少操作使数组递增
 */
public class minOperations {
    public static void main(String[] args) {

        int[] nums = {1, 5, 2, 4, 1};
        System.out.println(myCode(nums));

    }

    public static int myCode(int[] nums) {
        int ans = 0;
        for (int i = 1; i < nums.length; i++) {
            int target = Math.max(nums[i], nums[i - 1] + 1);
            ans += target - nums[i];
            nums[i] = target;
        }
        return ans;
    }
}
